<%@ page import="com.sun.org.apache.xpath.internal.operations.String" %>
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="mm" uri="/mytaglib" %> <%--引入自定义标签库--%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    //    request.setAttribute("key","123");
//    if (5 == 5) {
//        System.out.println("true");
//    } else {
//        System.out.println("false");
//    }
%>

<c:set scope="request" value="123" var="key"/>
${requestScope.key}
<c:if test="${5 eq 6}">
    5 == 5
</c:if>

<c:set scope="request" var="height" value="200"/>
<c:choose>
    <%-- 这是 html 注释 --%>
    <c:when test="${ requestScope.height > 190 }">
        <h2>小巨人</h2>
    </c:when>
    <c:when test="${ requestScope.height > 180 }">
        <h2>很高</h2>
    </c:when>
    <c:when test="${ requestScope.height > 170 }">
        <h2>还可以</h2>
    </c:when>
    <c:otherwise>
        <c:choose>
            <c:when test="${requestScope.height > 160}">
                <h3>大于 160</h3>
            </c:when>
            <c:when test="${requestScope.height > 150}">
                <h3>大于 150</h3>
            </c:when>
            <c:when test="${requestScope.height > 140}">
                <h3>大于 140</h3>
            </c:when>
            <c:otherwise>
                其他小于 140
            </c:otherwise>
        </c:choose>
    </c:otherwise>
</c:choose>
<%--java遍历--%>

<%

    for (int i = 0; i < 10; i++) {
%>
<%=i%>
<%}%>
<br>
<%--c:foreach--%>
<c:forEach begin="0" end="9" var="i">
    ${i}
</c:forEach>
<%--遍历数组--%>
<br>
<c:forEach items="${requestScope.arr}" var="a">
    ${a}
</c:forEach>
<br>
<%--遍历map--%>
<c:forEach items="${requestScope.map}" var="map">
    ${map} <br>
    ${map.key}-${map.value}
</c:forEach>

<%--遍历list--%>
<table border="1" cellspacing="0">
    <tr>
        <th>序号</th>
        <th>id</th>
        <th>username</th>
        <th>password</th>
    </tr>
    <c:forEach items="${requestScope.users}" begin="2" end="8" step="2" var="user" varStatus="status">
        <tr>
            <td>${status.count}</td>
            <td>${user.id}</td>
            <td>${user.username}</td>
            <td>${user.password}</td>
        </tr>
    </c:forEach>
</table>
<%
    request.setAttribute("num", 99.999999999);
    request.setAttribute("num1", 0.85);
    request.setAttribute("num2", 0.99999);
    request.setAttribute("date", new Date());
%></
>
<%--fmt格式化--%>
<fmt:formatNumber value="${requestScope.num}" pattern="#.0000">
</fmt:formatNumber>
<fmt:formatNumber value="${requestScope.num}" type="currency">
</fmt:formatNumber>
<fmt:formatNumber value="${requestScope.num}" type="percent"/>
<fmt:formatNumber value="${requestScope.num1}" type="percent">
</fmt:formatNumber>
<fmt:formatNumber value="${requestScope.num2}" type="percent"/>

<%--格式化日期--%>
<br>
<fmt:formatDate value="${requestScope.date}" pattern="yyyy-M-dd"/><br>
<fmt:formatDate value="${requestScope.date}" pattern="hh:mm:ss"/><br>
<fmt:formatDate value="${requestScope.date}" pattern="yyyy-MM-dd HH:mm:ss"/><br>

<mm:hello/>
<mm:message key="hello.title"/>
<br>
<%--上传表单--%>
<form action="${pageContext.request.contextPath}/upload" method="post" enctype="multipart/form-data">
    <input type="text" name="username"/><br>
    <input type="file" name="file"/><br>
    <input type="submit" value="上传"><br>
</form>
</body>
</html>
